﻿using System;
using System.Web.UI;
using Enyim.Caching;
using Enyim.Caching.Memcached;

namespace Practice
{
    public partial class Default : Page
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            
            var memcachedClient = new MemcachedClient();
            memcachedClient.FlushAll();
            memcachedClient.Store(StoreMode.Set, "Hello","Hello Memcached!");
        }

        protected override object SaveViewState()
        {
            var memcachedClient = new MemcachedClient();
            var value = memcachedClient.Get<string>("Hello");

            if (!string.IsNullOrEmpty(value))
            {
                indicator.Text = value;
            }

            return base.SaveViewState();
        }
    }
}